package com.meepo.feed.old.essay

import android.os.Bundle
import com.meepo.basic.schema.common.PageResult
import com.meepo.basic.schema.common.ResponseWrapper
import com.meepo.basic.schema.feed.Item
import com.meepo.feed.API
import com.xiaojinzi.component.support.ParameterSupport
import io.reactivex.Observable

object ObservableFactory {

    fun get(bundle: Bundle, page: Int, size: Int): Observable<ResponseWrapper<PageResult<Item>>> {
        val category = ParameterSupport.getString(bundle, "category") ?: ""
        val topicId = ParameterSupport.getString(bundle, "topicId") ?: ""
        val keyword = ParameterSupport.getString(bundle, "keyword") ?: ""
        val authorId = ParameterSupport.getString(bundle, "authorId") ?: ""
        val action = ParameterSupport.getString(bundle, "action") ?: ""


        // feed 流接口
        if (category != "") {
            return API.instance().fetchFeedItemsV2(category, keyword, topicId, action, page, size)
        }

        return API.instance().fetch(category, topicId, keyword, authorId, action, page, size)
    }
}